from django.conf import settings

def get_page(cur_page,total_page,num_page):
    '''
    cur_page:当前页
    total_page:总页数
    num_page:页条序列 123456
    '''
    if total_page < (settings.PAGE_MIDDLE_DATA)*2+1:
        return range(1,total_page+1)
    #分别算出前后的页码
    if cur_page < 5 and total_page > (settings.PAGE_MIDDLE_DATA)*2+1:
        return range(1,(settings.PAGE_MIDDLE_DATA)*2+2)

    #最小页码
    min_page = 1 if cur_page - num_page <= 0 else cur_page - num_page
    #最大页码
    max_page = total_page if total_page <= cur_page + num_page else cur_page + num_page
    return range(min_page,max_page+1)

